home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / gnu / amiga / gasldsrc.lha / gas-1.38 / m68k-opcode.h < prev    next >
C/C++ Source or Header  |  1991-04-07  |  8KB  |  201 lines

  1. /* Opcode table for m68000/m68020 and m68881.
  2.    Copyright (C) 1989, Free Software Foundation.
  3.  
  4. This file is part of GDB, the GNU Debugger and GAS, the GNU Assembler.
  5.  
  6. Both GDB and GAS are free software; you can redistribute and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 1, or (at your option)
  9. any later version.
  10.  
  11. GDB and GAS are distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. GNU General Public License for more details.
  15.  
  16. You should have received a copy of the GNU General Public License
  17. along with GDB or GAS; see the file COPYING.  If not, write to
  18. the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
  19.    
  20.  
  21. struct m68k_opcode
  22. {
  23.   char *name;
  24.   unsigned long opcode;
  25.   unsigned long  match;
  26.   char *args;
  27. };
  28.  
  29. /* We store four bytes of opcode for all opcodes because that
  30.    is the most any of them need.  The actual length of an instruction
  31.    is always at least 2 bytes, and is as much longer as necessary to
  32.    hold the operands it has.
  33.  
  34.    The match component is a mask saying which bits must match
  35.    particular opcode in order for an instruction to be an instance
  36.    of that opcode.
  37.  
  38.    The args component is a string containing two characters
  39.    for each operand of the instruction.  The first specifies
  40.    the kind of operand; the second, the place it is stored.  */
  41.  
  42. /* Kinds of operands:
  43.    D  data register only.  Stored as 3 bits.
  44.    A  address register only.  Stored as 3 bits.
  45.    R  either kind of register.  Stored as 4 bits.
  46.    F  floating point coprocessor register only.   Stored as 3 bits.
  47.    O  an offset (or width): immediate data 0-31 or data register.
  48.       Stored as 6 bits in special format for BF... insns.
  49.    +  autoincrement only.  Stored as 3 bits (number of the address register).
  50.    -  autodecrement only.  Stored as 3 bits (number of the address register).
  51.    Q  quick immediate data.  Stored as 3 bits.
  52.       This matches an immediate operand only when value is in range 1 .. 8.
  53.    M  moveq immediate data.  Stored as 8 bits.
  54.       This matches an immediate operand only when value is in range -128..127
  55.    T  trap vector immediate data.  Stored as 4 bits.
  56.  
  57.    k  K-factor for fmove.p instruction.   Stored as a 7-bit constant or
  58.       a three bit register offset, depending on the field type.
  59.  
  60.    #  immediate data.  Stored in special places (b, w or l)
  61.       which say how many bits to store.
  62.    ^  immediate data for floating point instructions.   Special places
  63.       are offset by 2 bytes from '#'...
  64.    B  pc-relative address, converted to an offset
  65.       that is treated as immediate data.
  66.    d  displacement and register.  Stores the register as 3 bits
  67.       and stores the displacement in the entire second word.
  68.  
  69.    C  the CCR.  No need to store it; this is just for filtering validity.
  70.    S  the SR.  No need to store, just as with CCR.
  71.    U  the USP.  No need to store, just as with CCR.
  72.  
  73.    I  Coprocessor ID.   Not printed if 1.   The Coprocessor ID is always
  74.       extracted from the 'd' field of word one, which means that an extended
  75.       coprocessor opcode can be skipped using the 'i' place, if needed.
  76.  
  77.    s  System Control register for the floating point coprocessor.
  78.    S  List of system control registers for floating point coprocessor.
  79.  
  80.    J  Misc register for movec instruction, stored in 'j' format.
  81.     Possible values:
  82.     000    SFC    Source Function Code reg
  83.     001    DFC    Data Function Code reg
  84.     002    CACR    Cache Control Register
  85.     800    USP    User Stack Pointer
  86.     801    VBR    Vector Base reg
  87.     802    CAAR    Cache Address Register
  88.     803    MSP    Master Stack Pointer
  89.     804    ISP    Interrupt Stack Pointer
  90.  
  91.     L  Register list of the type d0-d7/a0-a7 etc.
  92.        (New!  Improved!  Can also hold fp0-fp7, as well!)
  93.        The assembler tries to see if the registers match the insn by
  94.        looking at where the insn wants them stored.
  95.  
  96.     l  Register list like L, but with all the bits reversed.
  97.        Used for going the other way. . .
  98.  
  99.  They are all stored as 6 bits using an address mode and a register number;
  100.  they differ in which addressing modes they match.
  101.  
  102.    *  all                    (modes 0-6,7.*)
  103.    ~  alterable memory                (modes 2-6,7.0,7.1)(not 0,1,7.~)
  104.    %  alterable                    (modes 0-6,7.0,7.1)(not 7.~)
  105.    ;  data                    (modes 0,2-6,7.*)(not 1)
  106.    @  data, but not immediate            (modes 0,2-6,7.? ? ?)(not 1,7.?)  This may really be ;, the 68020 book says it is
  107.    !  control                    (modes 2,5,6,7.*-)(not 0,1,3,4,7.4)
  108.    &  alterable control                (modes 2,5,6,7.0,7.1)(not 0,1,7.? ? ?)
  109.    $  alterable data                (modes 0,2-6,7.0,7.1)(not 1,7.~)
  110.    ?  alterable control, or data register    (modes 0,2,5,6,7.0,7.1)(not 1,3,4,7.~)
  111.    /  control, or data register            (modes 0,2,5,6,7.0,7.1,7.2,7.3)(not 1,3,4,7.4)
  112. */
  113.  
  114. /* JF: for the 68851 */
  115. /*
  116.    I didn't use much imagination in choosing the 
  117.    following codes, so many of them aren't very
  118.    mnemonic. -rab
  119.  
  120.    P  pmmu register
  121.     Possible values:
  122.     000    TC    Translation Control reg
  123.     100    CAL    Current Access Level
  124.     101    VAL    Validate Access Level
  125.     110    SCC    Stack Change Control
  126.     111    AC    Access Control
  127.  
  128.    W  wide pmmu registers
  129.     Possible values:
  130.     001    DRP    Dma Root Pointer
  131.     010    SRP    Supervisor Root Pointer
  132.     011    CRP    Cpu Root Pointer
  133.  
  134.    f    function code register
  135.     0    SFC
  136.     1    DFC
  137.  
  138.    V    VAL register only
  139.  
  140.    X    BADx, BACx
  141.     100    BAD    Breakpoint Acknowledge Data
  142.     101    BAC    Breakpoint Acknowledge Control
  143.  
  144.    Y    PSR
  145.    Z    PCSR
  146.  
  147.    |    memory         (modes 2-6, 7.*)
  148.  
  149. */
  150.  
  151. /* Places to put an operand, for non-general operands:
  152.    s  source, low bits of first word.
  153.    d  dest, shifted 9 in first word
  154.    1  second word, shifted 12
  155.    2  second word, shifted 6
  156.    3  second word, shifted 0
  157.    4  third word, shifted 12
  158.    5  third word, shifted 6
  159.    6  third word, shifted 0
  160.    7  second word, shifted 7
  161.    8  second word, shifted 10
  162.    D  store in both place 1 and place 3; for divul and divsl.
  163.    b  second word, low byte
  164.    w  second word (entire)
  165.    l  second and third word (entire)
  166.    g  branch offset for bra and similar instructions.
  167.       The place to store depends on the magnitude of offset.
  168.    t  store in both place 7 and place 8; for floating point operations
  169.    c  branch offset for cpBcc operations.
  170.       The place to store is word two if bit six of word one is zero,
  171.       and words two and three if bit six of word one is one.
  172.    i  Increment by two, to skip over coprocessor extended operands.   Only
  173.       works with the 'I' format.
  174.    k  Dynamic K-factor field.   Bits 6-4 of word 2, used as a register number.
  175.       Also used for dynamic fmovem instruction.
  176.    C  floating point coprocessor constant - 7 bits.  Also used for static
  177.       K-factors...
  178.    j  Movec register #, stored in 12 low bits of second word.
  179.  
  180.  Places to put operand, for general operands:
  181.    d  destination, shifted 6 bits in first word
  182.    b  source, at low bit of first word, and immediate uses one byte
  183.    w  source, at low bit of first word, and immediate uses two bytes
  184.    l  source, at low bit of first word, and immediate uses four bytes
  185.    s  source, at low bit of first word.
  186.       Used sometimes in contexts where immediate is not allowed anyway.
  187.    f  single precision float, low bit of 1st word, immediate uses 4 bytes
  188.    F  double precision float, low bit of 1st word, immediate uses 8 bytes
  189.    x  extended precision float, low bit of 1st word, immediate uses 12 bytes
  190.    p  packed float, low bit of 1st word, immediate uses 12 bytes
  191. */
  192.  
  193. #define one(x) ((x) << 16)
  194. #define two(x, y) (((x) << 16) + y)
  195.  
  196. extern int numopcodes;
  197.  
  198. extern struct m68k_opcode *endop;
  199.  
  200. extern struct m68k_opcode m68k_opcodes[];
  201.